<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:29:"./themes/admin/tbb\index.html";i:1729740891;s:43:"D:\wwwroot\dpwkt.com\themes\admin\base.html";i:1576462546;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo $setup['title']; ?></title>
    <meta content="<?php echo $setup['keywords']; ?>" name="keywords" />
    <meta content="<?php echo $setup['description']; ?>" name="description" />
    <?php if($setup['ico'] != null): ?><link rel="shortcut icon" type="image/x-icon"  href="/public/uploads/<?php echo $setup['ico']; ?>"/><?php endif; ?>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
    <!--CSS引用-->
    
    <!--页面CSS-->
    <!--[if lt IE 9]>
    <script src="/public/static/js/html5shiv.min.js"></script>
    <script src="/public/static/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>

<!--tab标签-->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">信访记录</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form layui-form-pane" action="<?php echo url('admin/project/index'); ?>" method="get">
                    </form>
                    <hr>
                    <form class="layui-form" action="">
                       <table class="layui-table" lay-size="sm">
    <thead>
    <tr>
        <th style="width: 30px;">ID</th>
        <th>姓名</th>
        <th>身份证号</th>
        <th>电话号码</th>
        <th>省</th>
        <th>市</th>
        <th>区</th>
        <th>驳回原因</th>
        <th>图片</th>
        <th style="width: 130px;">创建时间</th>
        <th>状态</th> <!-- 添加状态列 -->
        <th style="width: 120px;">操作</th>
    </tr>
    </thead>
    <tbody>
    <?php if(is_array($record_list) || $record_list instanceof \think\Collection || $record_list instanceof \think\Paginator): if( count($record_list)==0 ) : echo "" ;else: foreach($record_list as $key=>$vo): ?>
    <tr>
        <td><?php echo $vo['id']; ?></td>
        <td><?php echo $vo['name']; ?></td>
        <td><?php echo $vo['idcard']; ?></td>
        <td><?php echo $vo['contact']; ?></td>
        <td><?php echo $vo['province']; ?></td>
        <td><?php echo $vo['city']; ?></td>
        <td><?php echo $vo['district']; ?></td>
        <td><?php echo $vo['reason']; ?></td>
        <td>
        <?php if(is_array($vo['files']) || $vo['files'] instanceof \think\Collection || $vo['files'] instanceof \think\Paginator): $i = 0; $__LIST__ = $vo['files'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$file): $mod = ($i % 2 );++$i;?>
        <img src="/public/uploads/<?php echo $file; ?>" style="max-width: 100px; max-height: 100px; margin: 5px;">
        <?php endforeach; endif; else: echo "" ;endif; ?>
        </td>
        <td><?php echo $vo['create_time']; ?></td>
        <td>
            <?php if($vo['status'] == 0): ?>
                处理中
            <?php elseif($vo['status'] == 1): ?>
                已处理
            <?php else: ?>
                已驳回
            <?php endif; ?>
        </td>
        <td style="width:200px;display:felx">
     
    <button type="button" class="layui-btn layui-btn-sm view-content" data-content="<?php echo $vo['content']; ?>">查看</button>
    <button type="button" class="layui-btn layui-btn-sm change-status" data-id="<?php echo $vo['id']; ?>" data-status="1">处理</button>
    <button type="button" class="layui-btn layui-btn-sm reject-status" style="background-color:red" data-id="<?php echo $vo['id']; ?>" data-status="2">驳回</button>

        </td>
    </tr>
    <?php endforeach; endif; else: echo "" ;endif; ?>
    </tbody>
</table>
                    </form>
                    <!--分页-->
                    <?php echo $record->render(); ?>
                </div>
            </div>
        </div>
    </div>
</div>

<!--页面-->

<!--JS引用-->
<script src="/public/static/js/jquery.min.js"></script>
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: "lib/index" //主入口模块
    }).use('index');
</script>

<script>
layui.use(['layer', 'form', 'upload'], function() {
    var $ = layui.jquery, layer = layui.layer, upload = layui.upload;
    var form = layui.form;

    // 数据导入
    var uploadInst = upload.render({
        elem: "#import",
        url: "<?php echo url('admin/tbb/import'); ?>",
        accept: 'file',
        before: function(obj) {
            layer.load();
        },
        done: function(res, index, upload) {
            layer.closeAll('loading');
            layer.msg('导入成功');
            setTimeout(function() {
                window.location.reload();
            }, 1500);
        },
        error: function(index, upload) {
            layer.closeAll('loading');
        }
    });

    // 通用删除
    $('.ajax-delete').on('click', function() {
        var _href = $(this).attr('href');
        layer.open({
            shade: false,
            content: '确定删除？',
            btn: ['确定', '取消'],
            yes: function(index) {
                $.ajax({
                    url: _href,
                    type: "get",
                    success: function(info) {
                        if (info.code === 1) {
                            setTimeout(function() {
                                location.href = info.url;
                            }, 1000);
                        }
                        layer.msg(info.msg);
                    }
                });
                layer.close(index);
            }
        });

        return false;
    });

    // 查看内容
    $('.view-content').on('click', function() {
        var content = $(this).data('content');
        layer.open({
            type: 1,
            title: '诉求内容',
            area: ['500px', '300px'],
            shadeClose: true,
            content: '<div style="padding: 20px;">' + content + '</div>'
        });
    });

    // 更改状态
    $('.change-status').on('click', function() {
        var id = $(this).data('id');
        var status = $(this).data('status');
        $.ajax({
            url: "<?php echo url('admin/tbb/changeStatus'); ?>",
            type: "post",
            data: {id: id, status: status},
            success: function(res) {
                if (res.code === 1) {
                    layer.msg('状态更新成功');
                    setTimeout(function() {
                        window.location.reload();
                    }, 1000);
                } else {
                    layer.msg(res.msg);
                }
            }
        });
    });

    // 驳回状态
    $('.reject-status').on('click', function() {
        var id = $(this).data('id');
        var status = $(this).data('status');
        layer.prompt({
            formType: 2,
            title: '请输入驳回理由',
            area: ['300px', '150px'] //自定义文本域宽高
        }, function(value, index, elem){
            $.ajax({
                url: "<?php echo url('admin/tbb/rejectStatus'); ?>",
                type: "post",
                data: {id: id, status: status, reason: value},
                success: function(res) {
                    if (res.code === 1) {
                        layer.msg('状态更新成功');
                        setTimeout(function() {
                            window.location.reload();
                        }, 1000);
                    } else {
                        layer.msg(res.msg);
                    }
                }
            });
            layer.close(index);
        });
    });
});

</script>

<!--页面JS脚本-->
</body>
</html>

